The StringJson function returns a value that corresponds to a jsonpath in a string in json format.
string @StringJson(string source, string jsonPath);
Parameters
string source : Target string
string jsonPath: The path to the json value to find (see the JsonPath recipe below)
Parameters
The json value that corresponds to the JsonPath.
Example 1)
buf = "{ "name": "John", "address": {"city": "Seoul", "street": "Main St."} }"
buf = @StringJson(buf,"$.name"); // result : buf = "John"
buf = @StringJson(buf,"$.address.city"); //result: buf = "Seoul"
Example 2)
filepath = 
"C:\\AutoBase\\Project\\ApiClientTest\\RESTAPIClient\\SolarPower_log.txt";
size = 
@FileGetSize(filepath);
handle = @FileOpen(filepath, "r");
if(handle != 0) 
{
@FileRead(handle, buf, size,1);
@FileClose(handle);
}
buf = 
@StringJson(buf,"$.inverter[0].pv");
$ST_inverter0_pv = buf;
Description: Read the SolarPower _log.txt file of the specified path in UTF-8 format and store the value corresponding to "$.inverter[0].pv" in the $ST_inverter0_pv tag.
Note) JSON Path Writing Guide
1. 
JSONPath Syntax Guide
1-1. Basic Structure
- JSON paths can start with $ 
symbol, which is optional
- Object properties are accessed using dot(.)
- 
Array elements are accessed using brackets([])
1-2. Array Access Methods
- [0], [1], [2] : Select specific index
- [*] : Select all elements
- [-1] 
: Select last element
¡Ø Brackets([]) are mandatory for array access
1-3. Expression Examples
For JSON starting with object:
$.store.book or 
store.book
For JSON starting with array:
$[0].name or [0].name
$[*].name or [*].name
1-4. Recommendations
- Including $ symbol is 
recommended for code clarity
- For nested structures, specifying the full 
path is recommended
2. Basic Syntax for Object({}) Format
$.name - 
'name' value of the root object
$.address.city - 'city' value inside 
'address' object
$.phones[0] - First item in the 'phones' array
$.phones[*] - All items in the 'phones' array
$.phones[*].number - 'number' 
values of all items in 'phones' array
$.*.city - 'city' values of all child 
objects
3. Basic Syntax for Array([]) Format
$[0] - First item in the 
array
$[*] - All items in the array
$[0].name - 'name' value of the first 
item
$[*].name - 'name' values of all items
$[0].items[*].value - All 
'value' values in 'items' array of first item
4. Using Filters
Object 
Format:
$.phones[?(@.type=='mobile')] - Items where type is 'mobile'
$.items[?(@.price > 100)] - Items where price is greater than 100
$.phones[?(@.type=='mobile')].number - Number values where type is 'mobile'
Array Format:
$[?(@.category=='income')] - Items where category is 
'income'
$[?(@.amount > 1000)] - Items where amount is greater than 1000
$[?(@.category=='expense')].items[*] - All items where category is 'expense'
Version Information
Supported Version: 10.3.6.24 or higher
Related helps